<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all"/>
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <form class="form-horizontal  layui-form" onsubmit="return false" id="form">
        <fieldset>
            <input type="hidden" id="userid" name="userid">

            <div class='form-group'>
                <label class='col-md-2 control-label'>用户名</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='username' type='text' name='username' id='username'
                           data-bv-notempty='true' data-bv-notempty-message='username 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>用户昵称</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='nickname' type='text' name='nickname' id='nickname'
                           data-bv-notempty='true' data-bv-notempty-message='nickname 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>手机号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='phone' type='text' name='phone' id='phone'
                           data-bv-notempty='true' data-bv-notempty-message='phone 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>用户状态</label>
                <div class='col-md-10'>
                    <select name="status" class="form-control input-sm" id="status">
                    </select>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>真实姓名</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='realname' type='text' name='realname' id='realname'
                           data-bv-notempty='false' data-bv-notempty-message='realname 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>律师执业证号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='workCode' type='text' name='workCode' id='workCode'
                           data-bv-notempty='false' data-bv-notempty-message='workCode 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>地区名字</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='areaName' type='text' name='areaName' id='areaName'
                           data-bv-notempty='false' data-bv-notempty-message='areaName 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>地区id</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='comid' type='text' name='comid' id='comid'
                           data-bv-notempty='false' data-bv-notempty-message='comid 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>律师所在律所</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='lawfirm' type='text' name='lawfirm' id='lawfirm'
                           data-bv-notempty='false' data-bv-notempty-message='lawfirm 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师编号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='licensenumber' type='text' name='licensenumber' id='licensenumber'
                           data-bv-notempty='false' data-bv-notempty-message='licensenumber 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>身份证号</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='idnumber' type='text' name='idnumber' id='idnumber'
                           data-bv-notempty='false' data-bv-notempty-message='idnumber 不能为空'>
                </div>
            </div>

            <input class='form-control' placeholder='field' type='hidden' name='field' id='field'>


            <div class="form-group">
                <label class="col-md-2 control-label">律师领域</label>
                <div class=" col-md-10">
                    <div id="fuxuankuang">

                    </div>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师寄语</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='content' type='text' name='content' id='content'
                           data-bv-notempty='false' data-bv-notempty-message='content 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>教育背景</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='education' type='text' name='education' id='education'
                           data-bv-notempty='false' data-bv-notempty-message='education 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>认证资质</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='thirdlevel' type='text' name='thirdlevel' id='thirdlevel'
                           data-bv-notempty='false' data-bv-notempty-message='thirdlevel 不能为空'>
                </div>
            </div>
            <div class='form-group'>
                <label class='col-md-2 control-label'>律师服务人数</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='serverNumber' type='text' name='serverNumber'
                           id='serverNumber' data-bv-notempty='false' data-bv-notempty-message='serverNumber 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师好评率</label>
                <div class='col-md-10'>
                    <input class='form-control' placeholder='rating' type='text' name='rating' id='rating'
                           data-bv-notempty='false' data-bv-notempty-message='rating 不能为空'>
                </div>
            </div>

            <div class='form-group'>
                <label class='col-md-2 control-label'>律师状态</label>
                <div class='col-md-10'>
                    <select name="lawyerInspect" class="form-control input-sm" id="lawyerInspect">
                    </select>
                </div>
            </div>


            <div class="form-actions">
                <div class="row" align="center">
                    <div class="col-md-12">
                        <button class="btn btn-primary" onclick="location.href='mfflLawyerList.html'">返回</button>
                        <button class="btn btn-primary" type="submit" onclick="update()">
                            <i class="fa fa-save"></i> 保存
                        </button>
                    </div>
                </div>
            </div>

        </fieldset>
    </form>
</div>
<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', 'laydate'], function () {
        var layer = layui.layer;
        var form = layui.form;
    });

    initData();

    function initData() {
        var userid = getUrlParam("userid");
        if (userid != "") {
            $.ajax({
                type: 'get',
                url: '/mfflLawyer/' + userid,
                async: false,
                success: function (data) {
                    $('#userid').val(data.userid);
                    $('#username').val(data.username);
                    $('#nickname').val(data.nickname);
                    $('#phone').val(data.phone);
                    var str = '';
                    str += '<option value="1" ' + (data.status == '1' ? 'selected' : '') + ' >正常</option>';
                    str += '<option value="2" ' + (data.status == '2' ? 'selected' : '') + ' >锁定</option>';
                    $('#status').html(str);
                    $('#realname').val(data.realname);
                    $('#workCode').val(data.workCode);
                    $('#areaName').val(data.areaName);
                    $('#comid').val(data.comid);
                    $('#lawfirm').val(data.lawfirm);
                    $('#idnumber').val(data.idnumber);
                    $('#field').val(data.field);
                    var field = data.field;
                    $.ajax({
                        type: 'get',
                        url: '/client/mfflTypes/getLawyerType',
                        async: false,
                        success: function (data) {
                            var lawyerType = data.datas;
                            for (var i = 0; i < lawyerType.length; i++) {
                                $('#fuxuankuang').append('<input type="checkbox" ' + (field.indexOf(lawyerType[i].id) != '-1' ? 'checked' : '') + '   name="fxk" value="' + lawyerType[i].id + '" title="' + lawyerType[i].name + '" >')
                            }
                        }
                    });

                    $('#content').val(data.content);
                    $('#education').val(data.education);
                    $('#thirdlevel').val(data.thirdlevel);
                    $('#serverNumber').val(data.serverNumber);
                    $('#rating').val(data.rating);

                    var lawyerInspect = '';
                    lawyerInspect += '<option value="0" ' + (data.lawyerInspect == '0' ? 'selected' : '') + ' >未审核</option>';
                    lawyerInspect += '<option value="1" ' + (data.lawyerInspect == '1' ? 'selected' : '') + ' >审核通过</option>';
                    lawyerInspect += '<option value="2" ' + (data.lawyerInspect == '2' ? 'selected' : '') + ' >待审核</option>';
                    lawyerInspect += '<option value="3" ' + (data.lawyerInspect == '3' ? 'selected' : '') + ' >拒绝</option>';
                    $('#lawyerInspect').html(lawyerInspect);


                }
            });
        }
    }

    function update() {
        $('#form').bootstrapValidator();
        var bootstrapValidator = $("#form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (!bootstrapValidator.isValid()) {
            return;
        }

        var arr = new Array();
        $("input:checkbox[name='fxk']:checked").each(function (i) {
            arr[i] = $(this).val();
        })

        var formdata = $("#form").serializeObject();
        formdata.field = arr.join(",");

        $.ajax({
            type: 'put',
            url: '/mfflLawyer',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(formdata),
            success: function (data) {
                layer.msg("修改成功", {shift: -1, time: 1000}, function () {
                    location.href = "mfflLawyerList.html";
                });
            }
        });
    }

</script>
</body>
</html>
